package com.qf.controller;

import com.qf.entity.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {

    @RequestMapping(value = "/demo1")
    @ResponseBody
    public String demo1(@RequestBody User user){
        System.out.println(user);
        return "success中文";
    }
    @RequestMapping(value = "/demo2")
    @ResponseBody
    public List<User> demo2(@RequestBody User user, HttpServletResponse resp){
        System.out.println(user);

        List<User> users = new ArrayList<>();
        users.add(user);

        resp.setHeader("Access-Control-Allow-Origin","http://localhost:81");
        resp.addHeader("Access-Control-Allow-Origin","http://localhost:82");
        resp.setHeader("Access-Control-Allow-Credentials","true");

        return users;
    }

}
